package com.company.recruit.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.company.recruit.entity.*;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 
 * 
 * @author wanghengfeng
 * @email 2428284819@qq.com
 * @date 2021-12-02 17:05:21
 */
@Mapper
public interface RecruitDao extends BaseMapper<RecruitEntity> {

    List<EducationAnalyse> getEducationAnalyse();

    @Insert("insert into education_analyse(num,education) value(#{num},#{education})")
    void saveEducationAnalyse(@Param("num") Integer num, @Param("education") String education);

    List<RecruitNum> getRecruitNum();

    @Insert("insert into recruit_num(city,num) value(#{city},#{num})")
    void saveRecruitNum(@Param("city") String city, @Param("num") Integer num);

    @Select("select city,num from recruit_num where city like CONCAT( #{name} ,'%')")
    List<RecruitNum> getCity(@Param("name") String name);

    @Delete("delete from recruit_num where city like CONCAT( #{city} ,'%')")
    void deleteRecruitNum(@Param("city") String city);

    List<AreaAvgWage> getAreaAvgWage();

    void saveAreaAvgWage(AreaAvgWage data);

    @Select("select city,sum_min_wage,sum_max_wage,count_num from area_avg_wage where city like CONCAT( #{city} ,'%')")
    List<AreaAvgWage> getCityByAvg(@Param("city") String city);

    @Delete("delete from area_avg_wage where city like CONCAT( #{city} ,'%')")
    void deleteAreaAvgWage(String city);

    @Select("select * from area_avg_wage")
    List<AreaAvgWage> getAll();

    @Update("update area_avg_wage set avg_min_wage = #{avgMin},avg_max_wage = #{avgMax} where city like CONCAT( #{city} ,'%')")
    void saveAvg(@Param("city") String city, @Param("avgMin") Integer avgMin, @Param("avgMax") Integer avgMax);

    @Select("select * from education_analyse")
    List<EducationAnalyse> getAllEducationAnalyse();

    @Select("select * from recruit_num")
    List<RecruitNum> getAllRecruitNum();

    @Select("select experience as experience_type,count(*) as num from recruit group by experience")
    List<ExperienceTypeAnalyse> getAllExperienceTypeAnalyse();

    void saveExperienceType(ExperienceTypeAnalyse experienceType);

    @Select("select * from experience_type_analyse")
    List<ExperienceTypeAnalyse> getAllExperienceTypeAnalyseByClean();

    @Select("select welfare from recruit")
    List<String> getStartWelfare();

    WelfareAnalyse getWelfareAnalyse(@Param("data") String data);


    void saveWelfareAnalyse(@Param("welfareType") String welfareType, @Param("num") Integer num);

    @Select("select * from experience_type_analyse")
    List<ExperienceTypeAnalyse> getAllExperienceTypeAnalyseByList();

    @Select("select * from welfare_analyse")
    List<WelfareAnalyse> getWelfareByAnalyseByList();

    void saveRecruitEntity(RecruitMongo recruitEntity);

    @Select("select * from area_avg_wage")
    List<AreaAvgWage> getAllAvgByNew();

    @Delete("delete from area_avg_wage where city = #{city}")
    void deleteAvg(String city);

    @Delete("delete from recruit where city like CONCAT( #{city} ,'%')")
    void deleteRecruitNumByNew(String city);
}
